home *** CD-ROM | disk | FTP | other *** search
- /*
- sc_text_pak.c - convert a packet to ascii text
- */
- #include "sc.h"
- #include "sc_seer_globals.h"
- #include "pdl_data.h"
- #include "OUT.h"
-
- void flush_out()
- {int bufsize;
- /*draw the current line,then advance the display down one line*/
- /***********************************************************
- orginaly out_break was used to cause line breaks to only happen
- on full fields. This doesn't looks worse than having breaks on
- each string, so that is why the check for out_break is ifdefed out here.
- */
- #ifdef BREAK_ON_FIELDS
- if(out_break==NIL) /*if no break point on this line, */
- #endif
- out_break=out_pt; /*print whatever is here*/
- bufsize=out_break-out_start;
- (*out_flush)(out_start,bufsize); /* print this text*/
- /*bufsize=number of chars left in buffer after line break*/
- bufsize=out_pt-out_break;
- *out_start = ' '; /*indent lines after the first one one space*/
- BlockMove(out_break,out_start+1,(long)bufsize); /*move chars to buffer start*/
- out_pt=out_start+bufsize+1; /*set out_pt for remaining characters*/
- out_break=NIL; /*don't know where to break yet*/
- }
-
- /*
- print this string
- */
- void OUT_str(str)
- register char *str;
- {register int slen;
- slen=strlen(str); /*see how many characters long the string is*/
- if(((out_stop-out_pt)-slen) < 0) /*would this string overflow the buffer?*/
- flush_out(); /*yes, so free up some space*/
- BlockMove(str,out_pt,(long)slen); /*add on the current string*/
- out_pt += slen; /*advance string pointer over added characters*/
- }
-
- /*the current position is ok to break lines at*/
- void OUT_brk()
- {if(out_start!=out_pt)
- *out_pt++ =','; /* put out the seperator*/
- out_break = out_pt;
- }
-
- /*
- print the requested packet onto the current output stream.
- This works for printing to files and to the screen.
- */
- int text_pak(a_pak)
- uint32 a_pak;
- {SR_record gparg;
- int itemp;
-
- /*retrieve the desired packet from the seer queue*/
- gparg.x.a_getpak.pak_num=a_pak;
-
- itemp=seer_ctl(SRc_getpak,&gparg); /*read the packet*/
- if(itemp==SRe_notyet) /*packet not here yet?*/
- return true; /*not here, say so*/
- if(itemp!=SRe_noErr) /*got the packet?*/
- bomb(BOMB_sr_getpak,BMB_no_os,BMB_no_special); /*no die*/
-
- out_pt=out_start;
- out_break=NIL;
-
- /*print the header*/
- pdl_print((uint8 *)&gparg.x.a_getpak,
- GETPAK,
- sizeof(gparg.x.a_getpak));
- /*print the data packet*/
- pdl_print((uint8 *)gparg.x.a_getpak.pak_data,
- ATALK_root,
- gparg.x.a_getpak.pak_size);
-
- /*if the buffer has characters in it, empty them*/
- if(out_break!=NIL) /*if buffere is not empty*/
- out_break=out_pt; /*print everything this time*/
- flush_out(); /*print them*/
-
- return false;
- }
-
-